package com.hc.demo.controller;

import com.hc.demo.domain.Hospital;
import com.hc.demo.dto.ResultResponse;
import com.hc.demo.service.HospitalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class HospitalController {

    @Autowired
    HospitalService hospitalService;

    @RequestMapping("/listHospital")
    public ResultResponse listHospital(){
        return hospitalService.list();
    }

    @RequestMapping("/getHospitalById")
    public ResultResponse getHospitalById(@RequestBody Hospital hospital){
        return hospitalService.selectOneById(hospital.getHpId());
    }

    //模拟做医院预约数据排行榜
    @RequestMapping("/getHospitalData")
    public ResultResponse getHospitalData(){
        System.out.println("into getHos.................");
//        Map<String,Integer> map=new HashMap<>();
//        map.put("河池医院",50);
//        map.put("广州医院",150);
//        map.put("桂林医院",30);
//        map.put("贵港医院",50);  //[{河池医院,50},{河池医院,150}]
        List<Hospital> hospitalList=new ArrayList<>();
        Hospital hospital1=new Hospital();
        hospital1.setName("河池医院");
        hospital1.setValue(50);
        hospitalList.add(hospital1);

        Hospital hospital2=new Hospital();
        hospital2.setName("广州医院");
        hospital2.setValue(150);
        hospitalList.add(hospital2);

        Hospital hospital3=new Hospital();
        hospital3.setName("桂林医院");
        hospital3.setValue(30);
        hospitalList.add(hospital3);

        Hospital hospital4=new Hospital();
        hospital4.setName("贵港医院");
        hospital4.setValue(50);
        hospitalList.add(hospital4);

        return new ResultResponse(ResultResponse.SUCCESS_CODE,ResultResponse.SUCCESS_DESC,hospitalList);
    }



}
